package me.jessyan.armscomponent.app.mvp.model.mine;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

import io.reactivex.Observable;
import me.jessyan.armscomponent.commonsdk.core.ResultCodeHub;
import me.jessyan.armscomponent.commonsdk.http.BaseResponse;
import me.jessyan.armscomponent.app.R;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineHistoryContract;
import me.jessyan.armscomponent.app.mvp.model.entity.HistoryItem;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/08/2021 17:59
 * Description: describe of this class
 */
@ActivityScope
public class MineHistoryModel extends BaseModel implements MineHistoryContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public MineHistoryModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Observable<BaseResponse<List<HistoryItem>>> getHistoryList() {
        return getList();
    }

    private Observable<BaseResponse<List<HistoryItem>>> getList(){
        List<HistoryItem> list = new ArrayList<>();
        HistoryItem bean = new HistoryItem();
        bean.setBookImage(R.drawable.mine_ic_book_02);
        bean.setCourseName("布哈里圣训实录");
        bean.setLearningTime("2020.0818");
        list.add(bean);

        bean = new HistoryItem();
        bean.setBookImage(R.drawable.mine_ic_book_02);
        bean.setCourseName("布哈里圣训实录");
        bean.setLearningTime("2020.0818");
        list.add(bean);

        bean = new HistoryItem();
        bean.setBookImage(R.drawable.mine_ic_book_02);
        bean.setCourseName("布哈里圣训实录");
        bean.setLearningTime("2020.0818");
        list.add(bean);


        BaseResponse<List<HistoryItem>> response = new BaseResponse<>();
        response.setResult(list);
        response.setPage(1);
        response.setPageCount(10);
        response.setCode(ResultCodeHub.CODE_0);
        return  Observable.just(response).delay(1, TimeUnit.SECONDS);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }
}